/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Action;

import ActionForm.EmployeeForm;
import Bean.EmployeeBean;
import DAO.EmployeeDAO;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Kimjeyoo
 */
public class EmployeeProcess extends org.apache.struts.action.Action {
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        EmployeeForm empForm = (EmployeeForm) form;
        EmployeeBean empB = new EmployeeBean();
        empB.setDepartmentID(empForm.getDepartmentID());
        empB.setFirstName(empForm.getFirstName());
        empB.setLastName(empForm.getLastName());
        empB.setGender(empForm.isGender());
        empB.setDOB(empForm.getdOB());
        empB.setPhoneNumber(empForm.getPhoneNumber());
        empB.setEmail(empForm.getEmail());
        empB.setAddress(empForm.getAddress());
        empB.setPosition(empForm.getPosition());
        empB.setAccount(empForm.getAccount());
        empB.setPassword(empForm.getPassword());
        
        String Target ="";
        if (new EmployeeDAO().AddNewEmployee(empB) == 1) {
            Target = "addOk";
        } else {
            Target = "addNo";
        }
        return mapping.findForward(Target);
    }
}
